fprintf(stderr, "A Warning be upon Ye: Here Be Dragons!\nThis program is incomplete, ill-considered, and unreliable!\nDo not Rely on without Consideration of Completing the program...\n\n");
if (argc < 3) {
fprintf(stderr,"usage:%s %s calfile # Calfile will be overwritten!\n",argv[0],TTYPrompt);
exit(2);
}
if (!(sd = pi_socket(PI_AF_SLP, PI_SOCK_STREAM, PI_PF_PADP))) {
perror("pi_socket");
exit(1);
}
pipe(&in[0]);
pipe(&out[0]);
if(!fork()) {
close(in[1]);
close(out[0]);
dup2(in[0],fileno(stdin));
dup2(out[1],fileno(stdout));
system("ical -f -");
exit(0);
}
ical.w = in[1];
ical.r = out[0];
/*ical = Tcl_CreateInterp();
app_init(ical);*/
Tcl_VarEval(&ical, "calendar calmain ",argv[2]);
abs.ical = &ical;
abs.cal = "calmain";
addr.pi_family = PI_AF_SLP;
strcpy(addr.pi_device,argv[1]);
ret = pi_bind(sd, (struct sockaddr*)&addr, sizeof(addr));
if(ret == -1) {
perror("pi_bind");
exit(1);
}
ret = pi_listen(sd,1);
if(ret == -1) {
perror("pi_listen");
exit(1);
}
sd = pi_accept(sd, 0, 0);
if(sd == -1) {
perror("pi_accept");
exit(1);
}
/* Ask the pilot who it is. */
dlp_ReadUserInfo(sd,&U);
/* Tell user (via Pilot) that we are starting things up */
dlp_OpenConduit(sd);
/* Open the Datebook's database, store access handle in db */